import os
import pandas as pd
import pdb

def build_image_path_dataframe(folder_path):
    """
    构建包含文件名和绝对路径的DataFrame
    
    Args:
        folder_path (str): 图片文件夹路径
        
    Returns:
        pd.DataFrame: 两列（filename, abs_path）的DataFrame
    """
    # 获取文件夹下所有文件（可过滤特定格式，如.jpg/.png）
    files = [f for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))]
    
    # pdb.set_trace()
    # 构建绝对路径
    abs_paths = [os.path.abspath(os.path.join(folder_path, f)) for f in files]
    
    # 创建DataFrame
    df = pd.DataFrame({
        'filename': files,
        'abs_path': abs_paths
    })
    
    return df

if __name__=='__main__':
    # 示例调用
    folder_path = "/data/shengjie/VITON-HD_ori/train/cloth"  # 替换为你的图片文件夹路径
    df_images = build_image_path_dataframe(folder_path)
    df_images.to_csv('viton.csv', index=False)
    # 查看结果
    print(df_images.head())
